{% extends "student/layout.html" %}

{% set page_title = __('查看学习记录') %}

{% block content %}
    {% if course_map and course_map.startswith('evaluation') %}
        <style>
            th {
                text-align: center;
                background-color: #e2e2e2;
                padding: 8px 0;
            }
            table{
                padding:3px;
                text-align:center;
                border:1px #cccccc solid;
                margin-top:1px;
                width: 100%;
                font-family: "Helvetica Neue", Helvetica, sans-serif, "STHeiti", "Microsoft Yahei", Arial;
            }
            td {
                padding: 8px 0;
            }
            .nopass{
                color: #e36f7e;
            }
            .good{
                color: #f5a623;
            }
            .very-good{
                color: #dcb81c;
            }
            .great{
                color: #67B021;
            }
            .activitynotgoing {
                color: #9e9e9e;
            }
            .sessionnotgoing {
                color: #9e9e9e;
            }
            .unfinished {
                color: #9e9e9e;
            }
            </style>
        <table name='evaluation'  cellpadding="1" border='1'>
        <tr>
            <th>{{translate('上课时间')}}</th>
            <th>{{translate('总分')}}</th>
            <th>{{translate('评价')}}</th>
            <th>{{translate('学习课程')}}</th>
            <th>{{translate('小考核－演奏')}}</th>
            <th>{{translate('小考核－乐理')}}</th>
            <th>{{translate('小考核－听力')}}</th>
        </tr>

    {% for d in sessions %}
        <tr>
        <td rowspan={{ d.lessons | length }}>{{ d.time }}</td>
        <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ d.avg_score }}</span></td>
        <td rowspan={{ d.lessons | length }}><span class="{{ d.remark_class }}">{{ __(d.remark) }}</span></td>

{#        {% for l, score in d.lessons.iteritems() %}#}
            <td class="name" id="lesson_s.id">{{ translate(d.map + d.evaluation) }}</td>

            <td id="{{ d.lessons[1].evaluation_score.activity_id if 'evaluation_score' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_score' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {{ d.lessons[1].evaluation_score._score }}
                        {% if d.lessons[1].evaluation_score.exist_pic %}
                            <i class="iconfont icon-file"></i>
                        {% endif %}
                    {% endif %}
                </span>
            </td>

            <td id="{{ d.lessons[1].evaluation_theory.activity_id if 'evaluation_theory' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_theory' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {% if not d.lessons[1].evaluation_theory %}
                            {{translate('无此步骤')}}
                        {% else %}
                            {{ d.lessons[1].evaluation_theory._score }}
                        {% endif %}
                    {% endif %}
                </span>
            </td>

            <td id="{{ d.lessons[1].evaluation_listen.activity_id if 'evaluation_listen' in d.lessons[1]}}" >
                <span class="activity
                    {% if 'evaluation_listen' not in d.lessons[1] %}notgoing">
                        {{translate('未进行')}}
                    {% else %}">
                        {% if not d.lessons[1].evaluation_listen %}
                            {{translate('无此步骤')}}
                        {% else %}
                            {{ d.lessons[1].evaluation_listen._score }}
                        {% endif %}
                    {% endif %}
                </span>
            </td>
            </tr>

            {% if not loop.last%}<tr>{% endif %}
{#        {% endfor %}#}
    {% endfor %}
        </table>
    {% else %}
        {% if current_user.course_type == 'course_adults' or current_user.course_type == 'course_xi_yang_hong' %}
            <div class="m-table-top">
            <span class="sum-score">{{__('总分')}}</span>
            <span class="study-time">{{__('学习时间')}}</span>
            <span class="kala">{{__('卡拉PK')}}</span>
            <span class="kala">{{__('分句PK')}}</span>
            <span class="pk_score_slow">{{__('曲谱PK(慢速)')}}</span>
            <span class="pk_score_mid">{{__('曲谱PK(中速)')}}</span>
            <span class="qupu">{{__('曲谱PK(原速)')}}</span>
            <span class="act">{{__('小考核－演奏')}}</span>
        </div>
            <ul class="table-record table table-responsive" id="study_records">
            {% for d in data %}
                <li>
                    <span class="sum-score col">
                        <span class="{{ d.remark_class }}">{{__(d.remark)}}</span>
                    </span>
                    <span class="study-time col" onclick="location.href='{{ url_for('student.detail', course_map=map_num, lesson_id=d.lesson_id) }}'">
                        <div class="date">
                         {{ __(d.time[5:7] + '月') }}{{ d.time[8:] }}{{__('日')}}
                        </div>
                        <div class="name" id="{{ d.lesson_id }}">{{ d.number }}.{{ __(d.lesson) }}</div>
                    </span>
                    <span class="col kala {% if 'pk_kara' not in d %}notgoing">{{__('未进行')}}{% else %}"  id="{{ d.pk_kara.activity_id }}">
                            {% if d.pk_kara.score == '' %}
                                {{__('无卡拉PK')}}
                            {% else %}
                                {{ d.pk_kara.score}}
                            {% endif %}
                            {% if d.pk_kara.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                    <span class="col kala {% if 'pk_part' not in d %}notgoing">{{__('未进行')}}{% else %}" id="{{ d.pk_part.activity_id }}">
                            {% if d.pk_part.score == '' %}
                                {{__('无分句PK')}}
                            {% else %}
                                {{ d.pk_part.score}}
                            {% endif %}
                            {% if d.pk_part.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                    <span class="col pk_score_slow {% if 'pk_score_slow' not in d %}notgoing">{{__('未进行')}}{% else %}" id="{{ d.pk_score_slow.activity_id }}">
                            {% if d.pk_score_slow.score == '' %}
                                {{__('无曲谱PK')}}
                            {% else %}
                                {{ d.pk_score_slow.score}}
                            {% endif %}
                            {% if d.pk_score_slow.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                    <span class="col pk_score_mid {% if 'pk_score_mid' not in d %}notgoing">{{__('未进行')}}{% else %}" id="{{ d.pk_score_mid.activity_id }}">
                            {% if d.pk_score_mid.score == '' %}
                                {{__('无曲谱PK')}}
                            {% else %}
                                {{ d.pk_score_mid.score}}
                            {% endif %}
                            {% if d.pk_score_mid.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                    <span class="col qupu {% if 'pk_score' not in d %}notgoing">{{__('未进行')}}{% else %}" id="{{ d.pk_score.activity_id }}">
                            {% if d.pk_score.score == '' %}
                                {{__('无曲谱PK')}}
                            {% else %}
                                {{ d.pk_score.score}}
                            {% endif %}
                            {% if d.pk_score.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                    <span class="col act {% if 'test_play' not in d %}notgoing">{{__('未进行')}}{% else %}" id="{{ d.test_play.activity_id }}">
                            {% if d.test_play.score == '' %}
                                {{__('无分句PK')}}
                            {% else %}
                                {{ d.test_play.score}}
                            {% endif %}
                            {% if d.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}
                        {% endif %}
                    </span>
                </li>
            {% endfor %}
        </ul>
        {% else %}
            <div class="m-scontent">
            <div class="m-table-top">
            <span class="sum-score">{{__('总分')}}</span>
            <span class="study-time">{{__('学习时间')}}</span>
            <span class="kala">{{__('分句PK')}}</span>
            <span class="qupu">{{__('全曲PK')}}</span>
            <!-- <span class="nolight">{{__('无灯PK')}}</span> -->
            <span class="act">{{__('小考核－演奏')}}</span>
            <span class="theory">{{__('小考核－乐理')}}</span>
            <span class="listen">{{__('小考核－听力')}}</span>
            </div>
            <ul class="table-record table table-responsive">

                {% for d in data %}
                <li>
                    <span class="sum-score col" onclick="location.href='{{ url_for('student.detail', course_map='map2', lesson_id=d.lesson_id) }}'"><span class="{{ d.remark_class }}">{{ __(d.remark) }}</span></span>
                    <span class="study-time col" onclick="location.href='{{ url_for('student.detail', course_map='map2', lesson_id=d.lesson_id) }}'">
                        <div class="date">
                         {{ __(d.time[5:7] + '月') }}{{ d.time[8:] }}{{__('日')}}
                        </div>
                        <div class="name" id="{{ d.lesson_id }}">{{ d.number }}.{{ __(d.lesson) }}</div>
                    </span>
                    <span id="{{ d.pk_part.activity_id if 'pk_part' in d }}" class="col kala {% if 'pk_part' not in d %}notgoing">{{__('无分句PK')}}{% else %}">{{ d.pk_part.score}}<i class="iconfont icon-file"></i>{% endif %}</span>
                    <span id="{{ d.pk_full.activity_id if 'pk_full' in d }}" class="col qupu {% if 'pk_full' not in d %}notgoing">{{__('未进行')}}{% else %}">{{ d.pk_full.score}}{% if d.pk_full.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span>
                    <span id="{{ d.test_play.activity_id if 'test_play' in d }}" class="col act {% if 'test_play' not in d %}notgoing">{{__('未进行')}}{% else %}">{{ d.test_play.score }}{% if d.test_play.exist_pic %}<i class="iconfont icon-file"></i>{% endif %}{% endif %}</span>
                    <span id="{{ d.test_music_theory.activity_id if 'test_music_theory' in d }}" class="col theory {% if 'test_music_theory' not in d %}notgoing">{{__('未进行')}}{% else %}">{{ d.test_music_theory.score}}{% endif %}</span>
                    <span id="{{ d.test_listen.activity_id if 'test_listen' in d }}" class="col listen {% if 'test_listen' not in d %}notgoing">{{__('未进行')}}{% else %}">{{ d.test_listen.score}}{% endif %}</span>
                </li>
                {% endfor %}
                <!-- <li>
                    <span class="sum-score col" onclick="location.href='/student/detail/map1/old_knight'"><span class="nopass">加油</span></span>
                    <span class="study-time col" onclick="location.href='/student/detail/map1/old_knight'">
                        <div class="date">
                        07月07日
                        </div>
                        <div class="name" id="old_knight">12.昔日骑士</div>
                    </span>
                    <span id="" class="col kala">84 <i class="iconfont icon-file"></i>/98 <i class="iconfont icon-file"></i></span>
                    <span id="" class="col qupu">
                        88 <i class="iconfont icon-file"></i>
                    </span>
                    <span id="" class="col act notgoing">
                        未进行
                    </span>
                    <span id="2003" class="col theory ">1/2</span>
                    <span id="2006" class="col listen ">2/2</span>
                </li> -->
            </ul>
            </div>
        {% endif %}
        {% include "school/pagination.html" %}
    {% endif %}
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog  modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="modalTitle">{{__('成绩单')}}</h4>
          </div>
          <div class="modal-body">

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">{{__('关闭')}}</button>
          </div>
        </div>
      </div>
    </div>

{% endblock %}

{% block js %}
    <script type="text/javascript">
        $('.icon-file').bind('click',function(){

            {% if course_map and course_map.startswith('evaluation') %}
                var activity_id = $(this).parent().parent().attr('id');
            {% else %}
                var activity_id = $(this).parent().attr('id');
            {% endif %}

            var url = '/student/record/images/' + activity_id;
            $.get(url, function(data){
                if (data['code']!=0){
                    alert(data['msg']);
                    return;
                }else{
                    var htmlStr = '';
                    var imagePaths = data['data']['images'];
                    for (var i in imagePaths){
                        htmlStr += '<img width="800px" src="' + imagePaths[i] + '" />';
                    }
                    $('#myModal .modal-body').html(htmlStr);
                    $('#myModal').modal('show');
                    $('.modal-body>img').width('800px');
                }

            }, 'json');
        });
    </script>
{% endblock %}
